<?php

class MY_Loader extends CI_Loader {
    public function template($template_name, $vars = array(), $return = FALSE)
    {
        $content  = $this->view('header', $vars, $return);
        $content .= $this->view($template_name, $vars, $return);
        $content .= $this->view('footer', $vars, $return);

        if ($return)
        {
            return $content;
        }
    }
	
	function comma_to_point($number) {
		return str_replace(',','.',str_replace('.','',$number));
	}
	
	function point_to_comma($number) {
		return str_replace('.',',',$number);
	}
	
	function std_time($datetime, $slicer) {
		if($datetime != null || $datetime != '') {
			$datetime = explode(' ', $datetime);
			$date = $datetime[0];
			$time = $datetime[1];
			$date = explode($slicer, $date);
			$datetime = $date[2].'-'.$date[1].'-'.$date[0].' '.$time;
		}
		
		return $datetime;
	}
	
	function pdf_header() {
		$this->fpdf->Image(base_url('image/seulawah-logo.jpg'),1.5,0.5,3,3);
		$this->fpdf->Image(base_url('image/batu.jpg'),24,1,4,2);
		$this->fpdf->Image(base_url('image/seulawah_trans.png'),7,4,15,15);
		$this->fpdf->SetFont('Arial','B',20);
		$this->fpdf->Cell(28,0.7,'SEULAWAH HOTEL',0,0,'C');
		$this->fpdf->Ln();
		$this->fpdf->SetFont('Arial','',12);
		$this->fpdf->Cell(28,0.7,'Jl. Mawar 8, Batu, Malang Utara, 65312 Batu',0,0,'C');
		$this->fpdf->Ln();
		$this->fpdf->SetFont('Arial','',10);
		$this->fpdf->Cell(28,0.5,'Telp (0341) 594 955 / 594 981 - Fax: (0341) 594 988',0,0,'C');
		$this->fpdf->Line(1.5,3.7,28,3.7);
		$this->fpdf->Line(1.5,3.75,28,3.75);
		$this->fpdf->Ln(2);
	}
	
	function pdf_footer() {
		$this->fpdf->SetXY(0.5,-1);
		$this->fpdf->SetFont('Arial','',8);
		$this->fpdf->SetTextColor(50,50,50);
		$sess=$this->session->userdata('logged_in');
		$this->fpdf->Cell(1, 0.5, 'Printed on : '.date('d/m/Y H:i').' | Created by : '.$sess['emp_name'],0,'LR','L');
		$this->fpdf->SetX(27.5);
		$this->fpdf->Cell(1, 0.5, 'Page '.$this->fpdf->PageNo().'/{nb}',0,0,'R');
		$this->fpdf->SetTextColor(0,0,0);
	}
	
	function pdf_cell($x, $y, $text, $b, $a) {
		$old_x = $this->fpdf->GetX();
		$old_y = $this->fpdf->GetY();
		$this->fpdf->Multicell($x , $y, $text, $b, $a);
		$this->fpdf->SetXY($old_x+$x, $old_y);
	}
	
	function pdf_header_p() {
		$this->fpdf->Image(base_url('image/seulawah-logo.jpg'),1.5,0.5,3,3);
		$this->fpdf->Image(base_url('image/batu.jpg'),15.5,1,4,2);
		$this->fpdf->Image(base_url('image/seulawah_trans.png'),3,6,15,15);
		$this->fpdf->SetFont('Arial','B',20);
		$this->fpdf->Cell(18,0.7,'SEULAWAH HOTEL',0,0,'C');
		$this->fpdf->Ln();
		$this->fpdf->SetFont('Arial','',12);
		$this->fpdf->Cell(18,0.7,'Jl. Mawar 8, Batu, Malang Utara, 65312 Batu',0,0,'C');
		$this->fpdf->Ln();
		$this->fpdf->SetFont('Arial','',10);
		$this->fpdf->Cell(18,0.5,'Telp (0341) 594 955 / 594 981 - Fax: (0341) 594 988',0,0,'C');
		$this->fpdf->Line(1.5,3.7,19.5,3.7);
		$this->fpdf->Line(1.5,3.75,19.5,3.75);
		$this->fpdf->Ln(2);
	}
	
	function pdf_footer_p() {
		$this->fpdf->SetXY(0.5,-1);
		$this->fpdf->SetFont('Arial','',8);
		$this->fpdf->SetTextColor(50,50,50);
		$sess=$this->session->userdata('logged_in');
		$this->fpdf->Cell(1, 0.5, 'Printed on : '.date('d/m/Y H:i').' | Printed by : '.$sess['emp_name'],0,'LR','L');
		$this->fpdf->SetX(18.5);
		$this->fpdf->Cell(1, 0.5, 'Page '.$this->fpdf->PageNo().'/{nb}',0,0,'R');
		$this->fpdf->SetTextColor(0,0,0);
	}
}